<?php
// +----------------------------------------------------------------------
// | wttai [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.wttai.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 老司机 <wutongtai@wttai.com> <http://www.wttai.com>
// +----------------------------------------------------------------------

namespace Home\Controller;


class CountCodeController extends HomeController {
	
	/**
	 * 统计验证码
	 */
	 public function countCode(){
	     
	    $token=$_POST['token'];
	    $minute=$_POST['minute']?$_POST['minute']:10;//统计几分钟内的数据
	     
	    if($token!=md5('2017dongyu')) return $this->ajaxReturn(errorReturn('标志有误'));
	    
        $maxTime=time()-$minute*60;
        $minTime=time();
	     //select count(*)  as gcount from media_code where success=2 and type=1 and  send_time<unix_timestamp(now()) and send_tiem>unix_timestamp(now())-10*60
	    $where=array(
	         'type'=>1,
	         'success'=>2,
	    );
	     //$where['send_time']=array('lt',time());
	     //$where['send_time']=array('gt',$maxTime);
	     $where['_string'] = "send_time < $minTime  AND  send_time > $maxTime ";
	     
	     
	    $codeNum= M('Code')->where($where)->count(); 
	    return $this->ajaxReturn(successReturn($codeNum));
	 }
	 

}